# Contributor: Michał Polański <michal@polanski.me>
# Contributor: Nicolas Lorin <androw95220@gmail.com>
# Maintainer:
pkgname=usbguard
pkgver=1.1.1
pkgrel=1
pkgdesc="Software framework for implementing USB device authorization policies"
url="https://usbguard.github.io/"
license="GPL-2.0-or-later"
arch="all"
makedepends="
	autoconf
	automake
	libtool
	libqb-dev
	libsodium-dev
	protobuf-dev
	audit-dev
	libseccomp-dev
	libcap-ng-dev
	catch2
	pegtl
	asciidoc
	"
checkdepends="coreutils"
subpackages="
	libusbguard-static
	libusbguard:libs
	$pkgname-dev
	$pkgname-doc
	$pkgname-openrc
	$pkgname-bash-completion
	$pkgname-zsh-completion
	"
source="https://github.com/USBGuard/usbguard/releases/download/usbguard-$pkgver/usbguard-$pkgver.tar.gz
	usbguard.initd
	"

prepare() {
	default_prepare
	autoreconf -fiv
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--localstatedir=/var \
		--enable-static \
		--without-bundled-catch \
		--without-bundled-pegtl \
		--without-dbus \
		--without-polkit \
		--with-crypto-library=sodium
	make
}

check() {
	make check
}

package() {
	make install DESTDIR="$pkgdir"
	install -Dm755 "$srcdir"/$pkgname.initd "$pkgdir"/etc/init.d/$pkgname

	install -Dm644 scripts/bash_completion/usbguard \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 scripts/usbguard-zsh-completion \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
7810471a3778b4bca644565cefa2666f98d53c2747bff7262b9bbb0327e7dba7a1e8c067c96d89e6742ccec5f65410f4e273bf84ee2bb1fbc7ff5738df3af780  usbguard-1.1.1.tar.gz
9d6752f08df0ba510fa02c0c9b55a92f063297653480c4d8863f87f159dc51449a34643e75af7619146e2e53c91d479be91ecc0c9adc0c764d037f4df466e534  usbguard.initd
"
